
#import "WWMovieProcView.h"
#import "WWMovieProcViewIBInspector.h"

@implementation WWMovieProcViewIBInspector

- init 
{
   char buf[MAXPATHLEN + 1];
   id bundle = [NXBundle bundleForClass:[WWMovieProcView class]];
    

   [super init];

   tclProcBodySize = 256;
   tclProcBody = (char *)NXZoneCalloc([self zone], tclProcBodySize, sizeof(char));

   [bundle getPath:buf forResource:[[self class] name] ofType:"nib"];
   [NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];

   // since the textView was "hidden" inside the ScrollView, we couldn't do this in IB, so...
   [tclProcBodyText setDelegate:self];

   [self revert:self];

   return self;
}
//
- free
{
  return [super free];
}
//
- revert:sender 
{
  [tclProcName setStringValue:[object tclProcName]];
  [tclProcType setStringValue:[object tclProcType]]; 
  [tclProcArgs setStringValue:[object tclProcArgs]]; 
  [tclProcBodyText setText:[object tclProcBody]];
  [restrictProcNameSwitch setIntValue:[object restrictDropToSameName]];
  [restrictProcTypeSwitch setIntValue:[object restrictDropToSameType]];
  [sourceSwitch setIntValue:[object actAsSource]];
  [sinkSwitch setIntValue:[object actAsSink]];
  return [super revert:sender];
}
//
- ok:sender
{
  int   cnt;


  cnt = [tclProcBodyText textLength];
  while (cnt >= tclProcBodySize)
  {  tclProcBodySize *= 2;
     tclProcBody = (char *)NXZoneRealloc([self zone], tclProcBody, tclProcBodySize);
  }
  *tclProcBody = '\0';
  [tclProcBodyText getSubstring:tclProcBody start:0 length:(cnt + 1)];
  [object setTclProcBody:tclProcBody];

  [object setTclProcName:[tclProcName stringValue]];
  [object setTclProcType:[tclProcType stringValue]];
  [object setTclProcArgs:[tclProcArgs stringValue]];
  [object setRestrictDropToSameName:(BOOL)[restrictProcNameSwitch intValue]];
  [object setRestrictDropToSameType:(BOOL)[restrictProcTypeSwitch intValue]];
  [object setActAsSource:(BOOL)[sourceSwitch intValue]];
  [object setActAsSink:(BOOL)[sinkSwitch intValue]];

  return [super ok:sender]; 
}
//
- (BOOL)wantsButtons	{ return YES; }

// text delegate methods
- textDidChange:sender {  return [self touch:sender]; }



@end
